﻿using QuickChat_Service.Repositories.Repositories.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QuickChat_Service.Repositories.Repositories.Fakes
{
    public class FakeRepository<T> : IRepository<T> where T : class
    {
        protected List<T> DbSet;

        public FakeRepository()
        {
            this.DbSet = new List<T>();
        }

        public IQueryable<T> GetAll()
        {
            return DbSet.AsQueryable();
        }

        public T GetById(int id)
        {
            return DbSet.ElementAt(id);
        }

        public virtual void Add(T entity)
        {
            DbSet.Add(entity);
        }

        public virtual void Update(T entity, int targetId)
        {
            throw new InvalidOperationException("Update method is not valid for this object");
        }

        public void Delete(T entity)
        {
            DbSet.Remove(entity);
        }

        public virtual void Delete(int id)
        {
            throw new InvalidOperationException("Delete method is not valid for this object");
        }


        public void SaveChanges()
        {
            throw new NotImplementedException("Method implementation not needed");
        }
    }
}